/*
 *  Copyright [2012] Paulo de Tarso
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package revendedora.entidades;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import javax.persistence.*;

/**
 *
 * @author Tarso
 */
@Entity
@Table(name="TB_SUBREVEDEDORAS",schema="REVENDAAVON")
public class SubRevendedoras implements Serializable, Comparable<SubRevendedoras> {
    private static final long serialVersionUID = 8534715212070942596L;
    
    @Id @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;
    
    @Column(name="NOME", nullable=false)
    private String nome;
    
    @Column(name="TELEFONE", nullable=false)
    private String telefone;
    
    @Column(name="EMAIL", nullable=false)
    private String email;
    
    @Column(name="PERCENTUAL_GANHO", nullable=false)
    private Double percentualDeGanho;
    
    @OneToMany(cascade= CascadeType.MERGE, mappedBy="subrevendedora")
    private List<HistoricoDeCampanhas> historico;

    @Override
    public int compareTo(SubRevendedoras o) {
        return this.compareTo(o);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final SubRevendedoras other = (SubRevendedoras) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.nome, other.nome)) {
            return false;
        }
        if (!Objects.equals(this.telefone, other.telefone)) {
            return false;
        }
        if (!Objects.equals(this.email, other.email)) {
            return false;
        }
        if (!Objects.equals(this.percentualDeGanho, other.percentualDeGanho)) {
            return false;
        }
        if (!Objects.equals(this.historico, other.historico)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 71 * hash + Objects.hashCode(this.id);
        hash = 71 * hash + Objects.hashCode(this.nome);
        hash = 71 * hash + Objects.hashCode(this.telefone);
        hash = 71 * hash + Objects.hashCode(this.email);
        hash = 71 * hash + Objects.hashCode(this.percentualDeGanho);
        hash = 71 * hash + Objects.hashCode(this.historico);
        return hash;
    }

    @Override
    public String toString() {
        return "SubRevendedoras{" + "id=" + id + ", nome=" + nome + ", telefone=" + telefone + ", email=" + email + ", percentualDeGanho=" + percentualDeGanho + ", historico=" + historico + '}';
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public List<HistoricoDeCampanhas> getHistorico() {
        return historico;
    }

    public void setHistorico(List<HistoricoDeCampanhas> historico) {
        this.historico = historico;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Double getPercentualDeGanho() {
        return percentualDeGanho;
    }

    public void setPercentualDeGanho(Double percentualDeGanho) {
        this.percentualDeGanho = percentualDeGanho;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }
}
